<html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" href="css/demo01.css">
	</head>
	<body>
		<div id="div_container">
			<div id="div_fruit_list">
				<p class="center f30">欢迎使用水果库存后台管理系统</p>
				<div style="width: 60%;margin-left: 20%;text-align: right" >
					<form th:action="@{/fruit.do}" method="post" style="float: left">
						<input type="hidden" name="likeSearch" value="search"/>
						请输入查询的关键字:<input type="text" name="keyword" th:value="${session.keyword}"/>
						<input type="submit" value="查询" class="btn"/>
					</form>
<!--					<a href="./demo09.html" style="margin-bottom: 4px">添加新库存水果</a>-->
<!--					<a th:href="@{/fruit.do(operation=edit)}" style="margin-bottom: 4px">添加新库存水果</a>-->
					<a href="demo09.html" style="margin-bottom: 4px">添加新库存水果</a>
				</div>
				<table id="tbl_fruit">
					<tr>
						<th class="w20">名称</th>
						<th class="w20">单价</th>
						<th class="w20">库存</th>
						<th>操作</th>
					</tr>
					<tr th:if="${#lists.isEmpty(session.fruitlist)}">
						<td colspan="4">对不起，库存为空</td>
					</tr>
					<tr th:unless="${#lists.isEmpty(session.fruitlist)}" th:each="fruit:${session.fruitlist}">
						<td><a th:text="${fruit.fname}" th:href="@{/fruit.do(fid=${fruit.fid},operation=edit)}"></a></td>
						<td th:text="${fruit.price}"></td>
						<td th:text="${fruit.fcount}"></td>
						<td><a th:href="@{/fruit.do(fid=${fruit.fid},operation=del)}" onclick="return on()"><img src="imgs/del.jpg" class="delImg"/></a></td>
					</tr>
				</table>
				<div style="width: 60%;margin-left: 20%;border:0px;padding-top:4px;" class="center">
					<input type="button" value="首页" class="btn" th:onclick="page(1)">
					<input type="button" value="上一页" class="btn" th:onclick="|page(${session.pageNumber} -1 )|" th:disabled="${session.pageNumber == 1}">
					<input type="button" value="下一页" class="btn" th:onclick="|page(${session.pageNumber} +1 )|" th:disabled="${session.pageNumber == session.pageCount}">
					<input type="button" value="尾页" class="btn" th:onclick="|page(${session.pageCount})|">
				</div>
				<hr/>

			</div>
		</div>
	<script>
		function on(fid){
			alert("你确定删除吗？")
		}

		function page(pageNumber){
			window.location.href = "fruit.do?pageNumber=" + pageNumber
		}
	</script>

	</body>
</html>
